#ifndef WOLF_ENGINE_TEST_HPP
#define WOLF_ENGINE_TEST_HPP

#include "test.hpp"
#include "engine.hpp"

namespace wolf
{
    using namespace std;
    /**
     * @brief Tests if the engine is working
     *
     * No other objects are involved, so is just wait a predetermined number
     *  of frames and just kill the app.
     **/
    class EngineTest: public Test
    {
    public:
        /**
         * @brief Creates a test with the predetermined number of frames to run
         *
         * @param fqtd The quantity of frames to run.
         * @param frate The number of frames per second to use.
         **/
        EngineTest( unsigned fqtd, unsigned frate ) : Test( "Engine Starting" )
        {
            frameQtd = fqtd;
            frameRate = frate;
        }

        bool run()
        {
            Engine engine( Engine::DEBUG );
            engine.setVideoMode( 640, 480, 0 );
            engine.setFrameRate( frameRate );
            engine.start();
            for( unsigned i = 0; i < frameRate; ++ i )
            {
                if( engine.isRunning() )
                    engine.doFrame();
                else
                {
                    cout << "Engine halted by user at frame #" << i << endl;
                    return true;
                }
            }
            engine.end();
            cout << "Engine halted by timeout (all frames have ran)" << endl;
            return true;
        }
    private:
        unsigned frameQtd;
        unsigned frameRate;
    };
}

#endif // WOLF_ENGINE_TEST_HPP

